package com.itmentu.listener.direct;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Author：http://www.itmentu.com
 * @date： 2021/12/6 11:10
 * @Description：
 ***/
//@Component
public class MessageListener {

    /**
     * 消息监听
     */
    @RabbitListener(queues = "direct_queue")
    public void listener(String message){
        System.out.println("MessageListener->监听到的消息是-->"+message);
    }

    /**
     * 声明队列
     */
    @Bean
    public Queue topicQueue(){
        return QueueBuilder
                //指定队列名字
                .durable("direct_queue")
                //构建队列
                .build();
    }
}
